package com.ruoyi.web.pojo.request.warning;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.warning.WarningInsect;
import com.ruoyi.web.utils.BasePageQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class WarningInsectRequest extends BasePageQuery{

    @ApiModelProperty("昆虫类型 1 一类害虫 2 二类害虫 3 其他")
    private Integer insectType;

    @ApiModelProperty("昆虫名称")
    private String insectName;

    @ApiModelProperty("是否启用 0 启用 1 停用")
    @TableField("is_enable")
    private String isEnable;


    /**
     * @desc  构建查询条件
     * @author fwx 2024/2/1 14:25
     **/
    public void bulidWrapper(QueryWrapper<WarningInsect> query){
        //是否启用
        if(StringUtils.isNotBlank(this.getIsEnable())){
            query.lambda().eq(WarningInsect::getIsEnable,this.getIsEnable());
        }

        //昆虫名称
        if(StringUtils.isNotBlank(this.getInsectName())){
            query.lambda().like(WarningInsect::getInsectName,this.getInsectName());
        }

        //昆虫类型
        if(this.getInsectType() != null){
            query.lambda().eq(WarningInsect::getInsectType,this.getInsectType());
        }

        query.lambda().orderByAsc(WarningInsect::getIsEnable);
    }
}
